package solved;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;

/*
ID:		liluyan1
LANG:	JAVA
TASK:	fact4
*/
public class fact4 {
	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new FileReader("fact4.in"));
		PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter(
				"fact4.out")));
		new fact4().solve(f, out);
		out.close();
		System.exit(0);
	}
	
	private int extra2;
	
	private void solve(BufferedReader f, PrintWriter out) throws IOException {
		int N = read(f);
		int res = 1;
		for (int i=2; i<=N; i++) {
			res = res * divide5(divide2(i)) % 10;
		}
		
		for (int i=0; i<extra2; i++) {
			res = res * 2 % 10;
		}
		
		out.println(res);
	}
	
	private int divide2(int i) {
		while (i%2 == 0) {
			i /= 2;
			extra2++;
		}
		return i;
	}
	
	private int divide5(int i) {
		while (i%5 == 0) {
			i /= 5;
			extra2--;
		}
		return i;
	}
	
	public int read(BufferedReader f) throws IOException {
		return Integer.parseInt(f.readLine());
	}
}